package edu.uoc.tds.pec4.vista;

import edu.uoc.tds.pec4.gestor.GestorEvento;
import edu.uoc.tds.pec4.model.SS1_CentroDocente;
import edu.uoc.tds.pec4.model.SS2_Evento;
import edu.uoc.tds.pec4.util.ExceptionUtils;
import edu.uoc.tds.pec4.util.KeyValue;
import edu.uoc.tds.pec4.util.LanguageUtils;
import java.rmi.RemoteException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;

/**
 * Tecnicas de Desarrollo de Software - (UOC)
 * Clase para dar de alta un evento
 * @author Grupo Magicsoftware - Yolanda Jiménez Anaya
 * @version 1.0
 */

public class SS2_PantallaAltaEvento extends javax.swing.JPanel {
    
    private GestorEvento remotoEvento;
    
    public SS2_PantallaAltaEvento(GestorEvento remotoEvento) {
        this.remotoEvento = remotoEvento;
        initComponents();
        //Rellenamos el combo de centros
        jComboBoxCentro.setSelectedItem(jComboBoxCentro);
        setListCentrosToCombo(jComboBoxCentro);
        //Rellenamos el combo de tipos de evento
        jComboBoxTipo.setSelectedItem(jComboBoxTipo);
        setListTiposToCombo(jComboBoxTipo);
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelAltas = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextDes = new javax.swing.JTextArea();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jLabelRolRe = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabelEvRe = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabelUmbral = new javax.swing.JLabel();
        jTextFieldPrecio = new javax.swing.JTextField();
        jTextFieldCap = new javax.swing.JTextField();
        jTextFieldUmbral = new javax.swing.JTextField();
        jLabelFeLimite = new javax.swing.JLabel();
        jTextFeLim = new javax.swing.JTextField();
        jLabelTipo = new javax.swing.JLabel();
        jLabelNombre = new javax.swing.JLabel();
        jTextFieldNombre = new javax.swing.JTextField();
        jLabelFeIni = new javax.swing.JLabel();
        jTextFeIni = new javax.swing.JTextField();
        jLabelCentro = new javax.swing.JLabel();
        jComboBoxCentro = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabelUmbral1 = new javax.swing.JLabel();
        jTextFieldCre = new javax.swing.JTextField();
        jTextFieldDura = new javax.swing.JTextField();
        jTextFieldPlaz = new javax.swing.JTextField();
        jButtonAlta = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTextFeCele = new javax.swing.JTextField();
        jComboBoxTipo = new javax.swing.JComboBox();

        setPreferredSize(new java.awt.Dimension(664, 470));

        jPanelAltas.setPreferredSize(new java.awt.Dimension(664, 470));

        jTextDes.setColumns(20);
        jTextDes.setRows(5);
        jScrollPane4.setViewportView(jTextDes);

        jLabel5.setText("Descripcion:");

        jScrollPane3.setViewportView(jList2);

        jLabelRolRe.setText("Rol Requisito:");

        jScrollPane2.setViewportView(jList1);

        jLabelEvRe.setText("Eventos Requisito");

        jLabel4.setText("Creditos:");

        jLabel3.setText("Precio:");

        jLabelUmbral.setText("Capacidad:");

        jLabelFeLimite.setText("Fecha limite inscripciones:");

        jLabelTipo.setText("Tipo:");

        jLabelNombre.setText("Nombre:");

        jLabelFeIni.setText("Fecha Inicio inscripciones:");

        jTextFeIni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFeIniActionPerformed(evt);
            }
        });

        jLabelCentro.setText("Centro:");

        jLabel6.setText("Duracion (min):");

        jLabel7.setText("Plazas:");

        jLabelUmbral1.setText("Umbral (%):");

        jButtonAlta.setText("Alta");
        jButtonAlta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAltaActionPerformed(evt);
            }
        });

        jLabel1.setText("Fecha Celebracion:");

        javax.swing.GroupLayout jPanelAltasLayout = new javax.swing.GroupLayout(jPanelAltas);
        jPanelAltas.setLayout(jPanelAltasLayout);
        jPanelAltasLayout.setHorizontalGroup(
            jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAltasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelRolRe)
                    .addComponent(jLabelEvRe)
                    .addComponent(jLabelFeIni)
                    .addComponent(jLabel1)
                    .addComponent(jLabelFeLimite)
                    .addComponent(jLabel5)
                    .addComponent(jLabelTipo)
                    .addComponent(jLabelNombre)
                    .addComponent(jLabelCentro))
                .addGap(18, 18, 18)
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jComboBoxTipo, 0, 502, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelAltasLayout.createSequentialGroup()
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFeLim)
                            .addComponent(jTextFeCele)
                            .addComponent(jTextFeIni, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE))
                        .addGap(18, 25, Short.MAX_VALUE)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelUmbral)
                            .addComponent(jLabel6)
                            .addComponent(jLabel7))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldPlaz)
                            .addComponent(jTextFieldPrecio)
                            .addComponent(jTextFieldCre, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                        .addGap(18, 83, Short.MAX_VALUE)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelUmbral1)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jTextFieldUmbral, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextFieldCap)
                            .addComponent(jTextFieldDura)
                            .addComponent(jButtonAlta, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                    .addComponent(jTextFieldNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                    .addComponent(jComboBoxCentro, 0, 502, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelAltasLayout.setVerticalGroup(
            jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAltasLayout.createSequentialGroup()
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelAltasLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxCentro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelCentro))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelNombre))
                        .addGap(32, 32, 32)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelAltasLayout.createSequentialGroup()
                                .addComponent(jScrollPane4, 0, 0, Short.MAX_VALUE)
                                .addGap(14, 14, 14)
                                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTextFeCele, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6)
                                    .addComponent(jTextFieldCre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabelUmbral1)
                                    .addComponent(jTextFieldUmbral, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanelAltasLayout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
                                .addComponent(jLabel1)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFeIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelFeIni)
                            .addComponent(jLabelUmbral)
                            .addComponent(jTextFieldPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldCap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addGroup(jPanelAltasLayout.createSequentialGroup()
                        .addGap(63, 63, 63)
                        .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboBoxTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelTipo))
                        .addGap(126, 126, 126)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFeLim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelFeLimite)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldPlaz, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldDura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelEvRe)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanelAltasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelRolRe)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addComponent(jButtonAlta)
                .addGap(36, 36, 36))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanelAltas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(126, 126, 126))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanelAltas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAltaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAltaActionPerformed
        try {
            String Capacidad;
            SimpleDateFormat formatoDelTexto = new SimpleDateFormat("dd/MM/yyyy");
            Date FechaIni = null;
            Date FechaFin = null;
            Date FechaCelebracion = null;
            boolean result = false;
            String validarCamposObligatoriosMessage = validarCamposObligatorios(jComboBoxCentro.getItemAt(jComboBoxCentro.getSelectedIndex()).toString(),
                   jTextFieldNombre.getText(),
                   jTextFeCele.getText(),
		   jComboBoxTipo.getItemAt(jComboBoxTipo.getSelectedIndex()).toString(),
		   jTextFeIni.getText(),
		   jTextFeIni.getText());
            if ("".equals(validarCamposObligatoriosMessage)) {
              FechaIni = formatoDelTexto.parse(jTextFeIni.getText());
              FechaFin = formatoDelTexto.parse(jTextFeLim.getText());
              FechaCelebracion = formatoDelTexto.parse(jTextFeCele.getText());
              Capacidad = jTextFieldCap.getText();

              String v_CodigoCentro = "0";
              KeyValue kv1 = (KeyValue) jComboBoxCentro.getItemAt(jComboBoxCentro.getSelectedIndex());
              v_CodigoCentro = (String) kv1.getKey();

              String v_TipoEvento = "0";
              KeyValue kv2 = (KeyValue) jComboBoxTipo.getItemAt(jComboBoxTipo.getSelectedIndex());
              v_TipoEvento = (String) kv2.getKey();

              SS2_Evento EventoNuevo = new SS2_Evento(
                    Integer.parseInt(v_CodigoCentro),
                    jTextFieldNombre.getText(),
                    jTextDes.getText(),
                    new Date(),
                    FechaCelebracion,
                    "1",
                    new Date(),
                    "Create",
                    Integer.parseInt(v_TipoEvento),
                    Integer.parseInt(Capacidad),
                    FechaIni,
                    FechaFin,
                    jTextFieldDura.getText(),
                    Integer.parseInt(jTextFieldPrecio.getText()),
                    Integer.parseInt(jTextFieldPlaz.getText()),
                    Integer.parseInt(jTextFieldUmbral.getText()),
                    Integer.parseInt(jTextFieldCre.getText()));
              try {
                 result = remotoEvento.registraEvento(EventoNuevo);

                 if(!result){
                      jPanelAltas = new SS2_PantallaAltaEvento(remotoEvento);
                      ExceptionUtils.visualizarInformacion(LanguageUtils.getMessage("AltaEventos.Correcto"));
                 }else {
                    ExceptionUtils.visualizarError(LanguageUtils.getMessage("AltaEventos.Insertar"));
                }

              } catch (RemoteException ex) {
                 Logger.getLogger(SS2_PantallaAltaEvento.class.getName()).log(Level.SEVERE, null, ex);
                 ExceptionUtils.visualizarError(ExceptionUtils.ERR_Remote);
              }
            }else {
               ExceptionUtils.visualizarError(LanguageUtils.getMessage("AltaEventos.ERR_Validar") + validarCamposObligatoriosMessage);
            }

        } catch (ParseException ex) {
            Logger.getLogger(SS2_PantallaAltaEvento.class.getName()).log(Level.SEVERE, null, ex);
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("Acceso.ERR_Acceso"));
        }



    }//GEN-LAST:event_jButtonAltaActionPerformed

    private void jTextFeIniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFeIniActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextFeIniActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAlta;
    private javax.swing.JComboBox jComboBoxCentro;
    private javax.swing.JComboBox jComboBoxTipo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabelCentro;
    private javax.swing.JLabel jLabelEvRe;
    private javax.swing.JLabel jLabelFeIni;
    private javax.swing.JLabel jLabelFeLimite;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelRolRe;
    private javax.swing.JLabel jLabelTipo;
    private javax.swing.JLabel jLabelUmbral;
    private javax.swing.JLabel jLabelUmbral1;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    public static javax.swing.JPanel jPanelAltas;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextArea jTextDes;
    private javax.swing.JTextField jTextFeCele;
    private javax.swing.JTextField jTextFeIni;
    private javax.swing.JTextField jTextFeLim;
    private javax.swing.JTextField jTextFieldCap;
    private javax.swing.JTextField jTextFieldCre;
    private javax.swing.JTextField jTextFieldDura;
    private javax.swing.JTextField jTextFieldNombre;
    private javax.swing.JTextField jTextFieldPlaz;
    private javax.swing.JTextField jTextFieldPrecio;
    private javax.swing.JTextField jTextFieldUmbral;
    // End of variables declaration//GEN-END:variables


    /*
    * Metodo que comprueba que se han introducido los campos obligatorios
    */
    private String validarCamposObligatorios(String centro, String nombre,
            String FechaCelebracion,
            String tipo,
            String FechaIni,
            String FechaFin) {

       
        StringBuilder campos = new StringBuilder();
        try {
            if (centro == null || "".equals(centro)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.Centro"));
            }
            if (nombre == null || "".equals(nombre)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.NombreEvento"));
            }
            if (FechaCelebracion == null || "".equals(FechaCelebracion)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.FechaCelebracion"));
            }
            if (tipo == null || "".equals(tipo)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.TipoEvento"));
            }
            if (FechaIni == null || "".equals(FechaIni)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.FechaInicio"));
            }
            if (FechaFin == null || "".equals(FechaFin)) {
                campos.append(LanguageUtils.getMessage("AltaEventos.CampoObligatorio.FechaFin"));
            }

        } catch (Exception e) {
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("AltaEventos.ERR_Validar"));
        }

        return campos.toString();
    }

        /*
     * Metodo para rellenar el despegable de centros
     */
    private void setListCentrosToCombo(JComboBox combo) {
        try {
            List<SS1_CentroDocente> list = remotoEvento.dameListaCentros();
            if (list != null && list.size() > 0) {
                for (SS1_CentroDocente CentroDocente : list) {
                    combo.addItem(new KeyValue(Integer.toString(CentroDocente.getId()), CentroDocente.getNombre()));
                }
            }
        } catch (RemoteException ex) {
            ExceptionUtils.visualizarError(ExceptionUtils.ERR_Remote);
        } catch (Exception ex) {
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("AltaEvento.ERR_Centros"));
        }
    }


    /*
     * Metodo para rellenar el despegable de Tipos de Evento
     */
    private void setListTiposToCombo(JComboBox combo) {
        try {
            List<SS1_CentroDocente> list = remotoEvento.dameListaTipo();
            if (list != null && list.size() > 0) {
                for (SS1_CentroDocente CentroDocente : list) {
                    combo.addItem(new KeyValue(Integer.toString(CentroDocente.getId()), CentroDocente.getNombre()));
                }
            }
        } catch (RemoteException ex) {
            ExceptionUtils.visualizarError(ExceptionUtils.ERR_Remote);
        } catch (Exception ex) {
            ExceptionUtils.visualizarError(LanguageUtils.getMessage("AltaEvento.ERR_TipoEvento"));
        }
    }

}
